public class Test {
    public static void main(String[] args) {
        int[] height = {1,8,6,2,5,4,8,3,7};
        int ret = maxArea(height);
        System.out.println(ret);
    }
    //盛最多水的容器
    public static int maxArea(int[] height) {
        int left = 0;
        int right = height.length - 1;
        int v = 0;
        int max = v;
        while(left < right){
            if(right < left){
                v = right * (right - left);
                right--;
            }else {
                v = left * (right - left);
                left++;
            }
            max = (max > v) ? max : v;
        }
        return max;
    }
}
